package com.example.springbootwebfluxdemo.controller;

import com.example.springbootwebfluxdemo.pojo.Clickurl;
import com.example.springbootwebfluxdemo.pojo.Hook;
import com.example.springbootwebfluxdemo.service.ClickurlService;
import com.example.springbootwebfluxdemo.service.HookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.reactive.function.server.ServerRequest;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.util.List;

/**
 * @Author cailinhu
 * @Description TODO
 * @Date 2022/11/22 15:13
 * @Version 1.0
 */
@RestController
@RequestMapping("/api")
public class WebController {
    @Autowired
    HookService hookService;

    @RequestMapping("update")
    public Mono<Boolean> update(Hook hook){
      return  Mono.just(hookService.updateNameById(hook.getId(),hook.getName()));
    }



    @RequestMapping("all")
    public Mono<List<Hook>> all(){
        return  Mono.just(hookService.list());
    }

}
